<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <title>时钟</title>
    <style type="text/css">
        *{
            padding: 0;
            margin: 0;
        }
        .box{
            width: 320px;
            height: 320px;
            position: relative;
            margin: auto;
        }
        #clock{
            width: 100%;
            height: 100%;
            margin: auto;
            background: #ddd;
            list-style: none;
            position: relative;
            margin-top: 100px;
            padding: 20px;
            border-radius: 50%;
            border: 2px solid #333;
        }
        li{
            width: 160px;
            font-size: 30px;
            margin-top: 138px;
            position: absolute;
            transform-origin: right;
        }
        span{
            display: inline-block;
        }
        #hour{
            height: 90px;
            width: 6px;
            position: absolute;
            top: 90px;
            left: 178px;
            background: #f0f;
            transform-origin: bottom;
        }
        #min{
            height: 110px;
            width: 4px;
            position: absolute;
            top: 70px;
            left: 179px;
            background: #ff0;
            transform-origin: bottom;
        }
        #sec{
            height: 130px;
            width: 2px;
            position: absolute;
            top: 50px;
            left: 180px;
            background: darkgreen;
            transform-origin: bottom;
        }
    </style>
    <script type="text/javascript">
        function Clock(a,b,c,d){
            this.hours=a;
            this.min=b;
            this.sec=c;
            this.ulList=d;
            this.Road();
            this.Time();
        }
        Clock.prototype.Create=function(n){
            var arr=[9,10,11,12,1,2,3,4,5,6,7,8];
            var Li=document.createElement('li');
            Li.style.transform="rotate("+n*30+"deg)";
            var Span=document.createElement('span');
            Span.style.transform="rotate(-"+n*30+"deg)";
            Span.innerHTML=arr[n];
            this.ulList.appendChild(Li);
            Li.appendChild(Span);
        }
        Clock.prototype.Road=function(){
            for(var i=0;i<12;i++){
                this.Create(i);
            }
        }
        Clock.prototype.Time=function(){
            _this=this;
            getTime();
            function getTime(){
                var time = new Date();
                var h = time.getHours(); 
                var m = time.getMinutes();
                var s = time.getSeconds();
                _this.hours.style.transform="rotate("+(h*30+(m*6+s*0.1)/12)+"deg)";
                _this.min.style.transform="rotate("+(m*6+s*0.1)+"deg)";
                _this.sec.style.transform="rotate("+s*6+"deg)";
            }
            setInterval(getTime,1000);
        }
        window.onload=function(){
            var ulList=document.getElementById('clock')
            var hours=document.querySelector("#hour");
            var min=document.querySelector("#min");
            var sec=document.querySelector("#sec");
            var zhong=new Clock(hours,min,sec,ulList);
        }
    </script>
</head>
<body>
    <div class="box">
        <ul id="clock">
        </ul>
        <div id="hour"></div>
        <div id="min"></div>
        <div id="sec"></div>
    </div>
</body>
</html>